package com.example.shop.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by Administrator on 2016/3/15.
 */
public class OpenHelper extends SQLiteOpenHelper {
    private static  OpenHelper mOpenHelper;
    private OpenHelper(Context context) {
        super(context, DBconfig.DB_NAME, null, DBconfig.DB_VERSION);
    }
    public static void initOpenHelper(Context context){
        if (mOpenHelper==null){
            mOpenHelper=new OpenHelper(context);
        }
    }
    public static OpenHelper getOpenHelper(){
        return  mOpenHelper;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String table_seach_history=DBconfig.TABLE_NAME_SEARCH_HISTOTY;
        db.execSQL("create table "+table_seach_history+"(id integer primary key autoincrement,title text);");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
